<html>
<%@ include file="../../common/taglibs.jsp"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		
		<title><fmt:message key="format.message.system" /></title>
	</head>
  <body>
  <script type="text/javascript">
  Ext.namespace('azure', 'azure.common');
  azure.common.history = function() {
  	/* ----------------------- private属性 ----------------------- */
  	var store_history;
  	var grid_history;
  	var rec_history;
  	var cm_history;
  	var tree_history;
  	var form_history, win_history;
  	var f_enable;
  	var datas=[[2,2,2]];
  	/* ----------------------- private方法 ----------------------- */
  	function createCM() {
  		cm_history = new Ext.grid.ColumnModel([
  			{header:'<fmt:message key="format.history.Number" />',width:50,dataIndex : 'pgnum'},
  			{header:'<fmt:message key="format.history.openlertime" />',width:100,dataIndex : 'periodTime'},
  			{header:'<fmt:message key="format.history.gamename" />',width:80,dataIndex : 'gamename'},
  			{header:'<fmt:message key="format.history.atgameDesk" />',width:100,dataIndex : 'gameTablename'},
  			{header:'<fmt:message key="format.history.openlerNum" />',width:300,dataIndex : 'Resultlotteries'},
  			{header:'<fmt:message key="format.history.winCell" />',width:100,dataIndex : 'winCell'}
  		]);
  	}
  	function createStore() {
  		store_history = new Ext.data.Store({
			proxy : new Ext.data.HttpProxy({
				url : 'PeriodGame_findHistoryRecord.action'
			}),
			reader : new Ext.data.JsonReader({
				root : 'pager.data',
				totalProperty : 'pager.totalSize'
			}, [{
				name : 'pgno',
				mapping : 'pgno'
			}, {
			name : 'pgnum',
			mapping : 'periodNum'
		}, {
			name : 'gameTablename',
			mapping : 'tablename'
		}, {
			name : 'gamename',
			mapping : 'gamename'
		}, {
			name : 'Resultlotteries',
			mapping : 'lotteryNum'
		}, {
			name : 'periodTime',
			mapping : 'periodTime'
		}, {
			name : 'winCell',
			mapping : 'winCell'
		}])
		});

  	}
  	function createGrid() {
  		createCM();
  		createStore();
  		var year = new Ext.form.TextField( {
  			id : "year",
  			labelSeparator:'',
  			selectOnFocus : true,
  			width : 50
  		});
  		var month = new Ext.form.TextField( {
  			id : "month",
  			labelSeparator:'',
  			selectOnFocus : true,
  			width : 30
  		});
  		var day = new Ext.form.TextField( {
  			id : "day",
  			labelSeparator:'',
  			selectOnFocus : true,
  			width : 30
  		});
  		
  		grid_history = new Ext.grid.GridPanel({
  			store: store_history,
  			cm: cm_history,
  			width:800,
  			height:455,
  			renderTo: Ext.getBody(),
  			bbar: new Ext.PagingToolbar({
  				store: store_history,
  				displayInfo: true,
  				pageSize: 5,
				displayMsg : '<fmt:message key="format.content.pager" />',
				emptyMsg : '<fmt:message key="format.content.emptyMsg" />'
  			}),
  			
  			tbar: [year,'<fmt:message key="format.history.year" />',month,'<fmt:message key="format.history.month" />',day,'<fmt:message key="format.history.day" />',{text:'<fmt:message key="format.history.query" />',iconCls : 'icon-search',handler :query}]
  		});
  	}
  	function createTree() {
  		var root = new Ext.tree.AsyncTreeNode('<fmt:message key="format.history.game" />');
  		tree_history = new Ext.tree.TreePanel({
  			width:200,
  			autoHeight : true,
  			root: root,
  			loader: new Ext.tree.TreeLoader({dataUrl:'PeriodGame_getGameToJson.action'})
  		});
  		tree_history.on('click',function(node){
  			grid_history.show(Ext.getBody());

  			store_history.load({params:{start:0,limit:15,'gameTable.gtno':node.attributes.tid}});
     		});
  	}

  	function query(){
  		store_history.load({params:{start:0,limit:15}});
  	 }
  	
  	// 创建主界面
  	function createUI() {
  		createGrid();
  		createTree();
  		grid_history.hide();
  		new Ext.Panel({
  			height:535,
  			renderTo: 'historyLotteryDiv',
  			layout:'border',
  			items: [
  				{region: 'west', width: 200, items: tree_history},
  				{region: 'center', items: grid_history}
  			]
  		});
  	}

  	/* ----------------------- public方法 ----------------------- */
  	return {
  		//初始化
  		init : function() {
  			createUI();
  		}
  	};
  }();
  Ext.EventManager.onDocumentReady(azure.common.history.init, azure.common.history, true);
  </script>
  	<div id="historyLotteryDiv"></div>
  </body>
</html>
